package kr.hkit.androidcomplete01.ch06;

import kr.hkit.androidcomplete01_.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;

public class SetParameter extends Activity {
	private Button mLeftBtn;
	private Button mRightBtn;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ch06_setparameter);

		mLeftBtn = (Button) findViewById(R.id.btnleft);
		mRightBtn = (Button) findViewById(R.id.btnright);
		
		/*mLeftBtn.setOnClickListener(listener);
		mRightBtn.setOnClickListener(listener);*/
		/*mLeftBtn.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				setParam(3, 1);
			}

		});

		mRightBtn.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				setParam(1, 3);

			}
		});*/
	}
	
	public void mOnClick(View v){
		switch(v.getId()){
		case R.id.btnleft:
			setParam(3,1);break;
		case R.id.btnright:
			setParam(1,3);break;
		}
	}
	
	/*View.OnClickListener listener = new OnClickListener() {
		
		@Override
		public void onClick(View v) {
			switch(v.getId()){
			case R.id.btnleft:
				setParam(3,1);break;
			case R.id.btnright:
				setParam(1,3);break;
			}
			
		}
	};*/

	void setParam(int left, int right) {
		LinearLayout.LayoutParams lparam = (LinearLayout.LayoutParams) mLeftBtn
				.getLayoutParams();
		lparam.weight = left;
		mLeftBtn.setLayoutParams(lparam);

		LinearLayout.LayoutParams rparam = (LinearLayout.LayoutParams) mRightBtn
				.getLayoutParams();
		rparam.weight = right;
		mRightBtn.setLayoutParams(rparam);
	}
}
